//  this library.
import 'package:hktk_app/model/home/column_model.dart';
import 'package:hktk_app/model/subject/upload_save_model.dart';

/// 科目model
class CategoryModel {
  String? createdTime;
  String? modifyTime;
  String? createdBy;
  String? modifyBy;
  int? id;
  String? name;
  String? serverName;
  int? parentId;
  String? examId;
  String? industryId;
  int? sort;
  List<int>? versIds;
  int? showState;
  int? attribute;
  String? industryName;
  List<ColumnModel>? columns;
  String? examName;
  String? parent;
  List<String>? children;
  bool? haveColumn;
  UploadSaveModel? categoryRecords;
  int? authFlag;
  bool? selected;
  String? keyword;
  String? code;
  int? price;

  // 是否还要子科目
  bool? haveChild;
  bool? isSelect; // 是否选中

  CategoryModel({
    this.createdTime,
    this.modifyTime,
    this.createdBy,
    this.modifyBy,
    this.id,
    this.name,
    this.serverName,
    this.parentId,
    this.examId,
    this.industryId,
    this.sort,
    this.versIds,
    this.showState,
    this.attribute,
    this.industryName,
    this.columns,
    this.examName,
    this.parent,
    this.children,
    this.haveColumn,
    this.categoryRecords,
    this.authFlag,
    this.selected,
    this.keyword,
    this.code,
    this.price,
    this.haveChild,
    this.isSelect = false,
  });

  CategoryModel.fromJson(Map<String, dynamic> json) {
    createdTime = json['createdTime'];
    modifyTime = json['modifyTime'];
    createdBy = json['createdBy'];
    modifyBy = json['modifyBy'];
    id = json['id'];
    name = json['name'];
    serverName = json['serverName'];
    parentId = json['parentId'];
    examId = json['examId'];
    industryId = json['industryId'];
    sort = json['sort'];
    if (json["versIds"] != null) {
      versIds = json['versIds'].cast<int>();
    }
    showState = json['showState'];
    attribute = json['attribute'];
    industryName = json['industryName'];
    if (json['columns'] != null) {
      columns = <ColumnModel>[];
      json['columns'].forEach((v) {
        columns!.add(ColumnModel.fromJson(v));
      });
    }
    examName = json['examName'];
    parent = json['parent'];
    if (json["children"] != null) {
      children = json['children'].cast<String>();
    }
    haveColumn = json['haveColumn'];
    categoryRecords = json['categoryRecords'] != null
        ? UploadSaveModel.fromJson(json['categoryRecords'])
        : null;
    authFlag = json['authFlag'];
    selected = json['selected'];
    keyword = json['keyword'];
    code = json['code'];
    price = json['price'];
    haveChild = json['haveChild'];
    isSelect = json['isSelect'] ?? false;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['createdTime'] = createdTime;
    data['modifyTime'] = modifyTime;
    data['createdBy'] = createdBy;
    data['modifyBy'] = modifyBy;
    data['id'] = id;
    data['name'] = name;
    data['serverName'] = serverName;
    data['parentId'] = parentId;
    data['examId'] = examId;
    data['industryId'] = industryId;
    data['sort'] = sort;
    data['versIds'] = versIds;
    data['showState'] = showState;
    data['attribute'] = attribute;
    data['industryName'] = industryName;
    if (columns != null) {
      data['columns'] = columns!.map((v) => v.toJson()).toList();
    }
    data['examName'] = examName;
    data['parent'] = parent;
    data['children'] = children;
    data['haveColumn'] = haveColumn;
    if (categoryRecords != null) {
      data['categoryRecords'] = categoryRecords!.toJson();
    }
    data['authFlag'] = authFlag;
    data['selected'] = selected;
    data['keyword'] = keyword;
    data['code'] = code;
    data['price'] = price;
    data['haveChild'] = haveChild;
    data['isSelect'] = isSelect;
    return data;
  }
}
